<?php
/**
 * tpshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.tp-shop.cn
 * ----------------------------------------------------------------------------
 * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
 * ============================================================================
 * 2015-11-21
 */
namespace Mobile\Controller;

use Home\Logic\UsersLogic;
use Think\Page;
use Think\Verify;

class CoachController extends MobileBaseController
{

    public function _initialize()
    {
        parent::_initialize();
        $this->assign('navid', "coach");
    }

    /**
     * 教练员列表
     */

    public function coach_list()
    {
        $coach_list=M('coach')->where(array('is_open'=>1))->order('id ASC')->select();
        if(count($coach_list)<1){
            $msg ='暂无教练！';
            $this->error($msg,U('Index/index'));
        }
        $this->assign('lists', $coach_list);
        $this->display();
    }


    /**
     * 教练员详情
     */

    public function coach_detail()
    {
        //教练信息
        $coach_id = I('coach_id');
        $coach_info = M('coach')->where(array('id' => $coach_id))->find();

        //该教练担任的课程
        $kc_str='';
        if($coach_info['cate_id']>0){
            $kc_str?$kc_str.=','.$coach_info['cate_id']:$kc_str.=$coach_info['cate_id'];
        }
        if($coach_info['cate_id2']>0){
            $kc_str?$kc_str.=','.$coach_info['cate_id2']:$kc_str.=$coach_info['cate_id2'];
        }
        if($coach_info['cate_id3']>0){
            $kc_str?$kc_str.=','.$coach_info['cate_id3']:$kc_str.=$coach_info['cate_id3'];
        }


        $where['extend_cat_id']=52;
        $where['coach_cate_id']=array('in',$kc_str);
        $goods_list=M('goods')->where($where)->select();
        $this->assign('coach_info', $coach_info);
        $this->assign('lists', $goods_list);
        $this->display();
    }
}
